<?php
/**
 * Created by PhpStorm.
 * User: zhouyao
 * Date: 2017/10/10
 * Time: 下午4:43
 */

namespace App\Http\Controllers;

use App\User;
use Illuminate\Support\Facades\Auth;

class UserController extends Controller
{
    public function index()
    {
        $user = User::find(1);
        $user->attachRoles(1);//同时绑定多个角色传数组
    }

    public function checkRole()
    {
        $user = User::find(Auth::user()->getAuthIdentifier());
        $user_role = $user->hasRole('admin');
        dd($user_role);
    }

    public function checkPermission()
    {
        $user = User::find(Auth::user()->getAuthIdentifier());
        $user_permission = $user->hasPermission('product.create');
        dd($user_permission);
    }
}